@extends("admin::layouts.master")
@section("content")

    <form action="{{route('userrole',$id)}}" method="post">
        @csrf
        <div class="col-lg-12">
            <div class="card card-flat">
                <div class="card-header">给[{{$user['name']}}]分配角色</div>


                @foreach($role as $v)

                        <div class="form-group row pt-1 pb-1">

                            <div class="card-body">




                                <div style="display: inline" class="col-12 col-sm-8 col-lg-6 form-check mt-2">


                                        <label class="custom-control custom-checkbox custom-control-inline">
                                            {{--判断用户拥有哪些角色--}}
                                            <input type="checkbox" name="name[]" value="{{$v['name']}}" @if($user->hasRole($v['name'])) checked  @endif  class="custom-control-input" ><span class="custom-control-label">
                                                {{$v['title']}}
                                            </span>
                                        </label>


                                </div>

                            </div>

                        </div>

                @endforeach

                <a style="float: right" href="javascript:window.history.back()">返回上一级</a>

            </div>

            {{--注意，这里不能使用a标签的原因，a标签跳转不能把内容带过去，但是form表单可以--}}
            {{--<a href="{{route('power')}}" class="btn btn-success">确定分配</a>--}}

            <button type="submit" class="btn btn-success">分配角色</button>


        </div>

    </form>


@endsection